{extend name="base" /}
{block name="content"}
<script src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
<div class="m-main-title">
    <div class="m-container-fluid">
        <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
        <span class="icon-angle-right"></span>
        <span>商城</span>
        <span class="icon-angle-right"></span>
        <span>会员价格</span>
        <span class="icon-angle-right"></span>
        <span>角色商品</span>
        <a class="u-flush"><i class="icon-repeat"></i></a>
    </div>
</div>

<div class="m-main-content">
    <div class="m-container">
        <table class="m-table">
            <tr>
                <th>
                    <div class="m-options cf">
                        <div class="m-opts fl"><a href="javascript:;" class="u-btn"><i class="icon-plus"></i>选择商品</a></div>
                        <div class="m-search fr">
                            <form action="" class="layui-form">
                                <label for="goods_name">商品名称</label>
                                <input type="text" name="goods_name" id="goods_name" class="u-ipt u-ipt-def" placeholder="请输入要查询的名称" value="{$goods_name}" />
                                <input type="submit" class="u-btn u-search" value="查看" />
                            </form>
                        </div>
                    </div>
                </th>
            </tr>
        </table>
        <form class="layui-form m-list-form">
            <table class="m-table">
                <tbody class="datas">
                <tr>
                    <th width="5%">ID</th>
                    <th width="10%">商品名称</th>
                    <th width="10%">价格</th>
                    <th width="10%">库存</th>
                    <th width="10%">操作</th>
                </tr>
                {foreach name="list" item="v"}
                <tr>
                    <td>{$v.id}</td>
                    <td>{$v.goods_name}</td>
                    <td>{$v.sale_price}</td>
                    <td>{$v.goods_stock}</td>
                    <td class="m-opt">
                        <a href="{:url('roleadd', ['id' => $v.id])}" title="">设置角色价格</a>
                        <a href="javascript:;" title="删除" class="a-u-del" data-id="{$v.id}"><i class="icon-trash"></i></a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </form>

        {include file="public:page" /}
    </div>
</div>
{/block}{block name="extrajs"}
{include file="laypage" /}
<script>
    $(function(){
        layui.use('layer', function(){
            $('.u-btn').on('click', function () {
                layer.open({
                    type: 2,
                    title: '商品',
                    shadeClose: false,
                    shade: 0,
                    area: ['96%', '90%'],
                    content: '/manage/role_goods/getgoods'//iframe的url
                });
            });
        })
    });

    /**
     * 删除
     */
    $('.a-u-del').on('click', function(){
        var id = $(this).attr('data-id');
        dialog.confirm('您确定删除此信息吗？', function(){
            $.get('/manage/role_goods/delRoleDel',{goods_id:id},function (res) {
                if(res.code===1){
                    layer.msg(res.msg);
                    setTimeout(function () {
                        window.location.reload();
                    },500);
                }else{
                    layer.msg(res.msg)
                }
            })
        });
        return false;
    });
</script>
{/block}